package com.ruoyi.law.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.PageCondition;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.law.domain.entity.LawNewsType;
import com.ruoyi.law.service.ILawNewsTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 新闻类别 前端控制器
 * </p>
 *
 * @author code
 * @since 2022-12-11
 */
@Api(tags = "新闻类别")
@RestController
@RequestMapping("/newsType")
public class LawNewsTypeController extends BaseController {

    @Autowired
    private ILawNewsTypeService newsTypeService;

    @Anonymous
    @ApiOperation("列表")
    @GetMapping("/list")
    public R<Page<LawNewsType>> list(PageCondition<LawNewsType> pageCondition) {
        Page<LawNewsType> page = newsTypeService.page(pageCondition.toPage());
        return R.ok(page);
    }

    @Anonymous
    @ApiOperation("详情")
    @GetMapping("/info")
    public R<LawNewsType> info(Long id) {
        LawNewsType lawNewsType = newsTypeService.getById(id);
        return R.ok(lawNewsType);
    }

    @ApiOperation("新增")
    @PostMapping("/save")
    public R<Object> save(@RequestBody LawNewsType lawNewsType) {
        newsTypeService.save(lawNewsType);
        return R.ok();
    }

    @ApiOperation("修改")
    @PostMapping("/update")
    public R<Object> update(@RequestBody LawNewsType lawNewsType) {
        newsTypeService.updateById(lawNewsType);
        return R.ok();
    }

    @ApiOperation("删除")
    @PostMapping("/delete")
    public R<Object> delete(@RequestBody Long id) {
        newsTypeService.removeById(id);
        return R.ok();
    }

}
